// 成功的操作
const p1 = new Promise((resolve, reject) => {
    setTimeout(() => resolve("A"), Math.floor(Math.random() * 1000));
});
const p2 = new Promise((resolve, reject) => {
    setTimeout(() => resolve("B"), Math.floor(Math.random() * 1000));
});
const p3 = new Promise((resolve, reject) => {
    setTimeout(() => resolve("C"), Math.floor(Math.random() * 1000));
});

(async function () {
    const result = await Promise.any([p1, p2, p3]);
    console.log(result); // 输出结果可能是 "A", "B" 或者 "C"
})();

// 失败的操作
const p = new Promise((resolve, reject) => reject());

try {
    (async function () {
        const result = await Promise.any([p]);
        console.log(result);
    })();
} catch (error) {
    console.log(error.errors); // AggregateError: All promises were rejected
}